package com.yunyu.biz.taskfactory.taskBatch;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 * 抽象时间
 *
 * @auther lihui
 * @date 2019-07-25 21:53
 */
public abstract class AbstractTaskBatch implements TaskBatch {
    public String findDependTaskBatchID(Date date, String taskName, Map<String, Object> params) {
        return null; // 默认情况下，没有依赖任务
    }

    public String createBatchID(Date date, Map<String, Object> params) {
        if (date == null) {
            date = new Date(); // 默认当前时间
        }

        String dataFormat = (String) params.get("dataFormat");
        if (null == dataFormat) {
            dataFormat = "yyyyMMddHH"; // 默认时间精确到小时
        }

        SimpleDateFormat sdf = new SimpleDateFormat(dataFormat);

        return sdf.format(date);
    }

}
